import CryptoJS from 'crypto-js'
// AES对称加密
export function encryptionValue(value, key = 'thanks66', iv = 'thanks88') {
  value = value.toString() // 数字加密会报错，转成字符串
  key = CryptoJS.enc.Utf8.parse(key)
  iv = CryptoJS.enc.Utf8.parse(iv)
  const encrypted = CryptoJS.AES.encrypt(value, key, { iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
  return encrypted.toString()
}
// AES对称解密
export function decryptionValue(value, key = 'thanks66', iv = 'thanks88') {
  key = CryptoJS.enc.Utf8.parse(key)
  iv = CryptoJS.enc.Utf8.parse(iv)
  const decrypt = CryptoJS.AES.decrypt(value, key, { iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 });
  return decrypt.toString(CryptoJS.enc.Utf8)
}

